<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<html>
<head>
<script type="text/javascript">
	$(document).ready(function() {
		console.log('$start_loginForm');
		
		var $form = $('#s_menu_lgn_frm').find('form');
		
		$('#login_btn').click(function(){
			var url = '/home/common/login.zpr';
			
			var isValid = true;
			
			if( $('#login_email').val() == '' ) {
				$('label[for="login_email"]').html('이메일: <span style="color:red; float:right;">이메일을 입력 해 주세요.</span>');
				isValid = false;
			}
			else {
				$('label[for="login_email"]').html('이메일:');
			}

			if( $('#login_password').val() == '' ) {
				$('label[for="login_password"]').html('비밀번호: <span style="color:red; float:right;">비번을 입력 해 주세요.</span>');
				isValid = false;
			}
			else {
				$('label[for="login_password"]').html('비밀번호:');
			}
			
			console.log( $form.serialize() );
			
			if(!isValid) return;
			
			$.post(url , $form.serialize() , function(data){
				if(data == 'Y') {
					// 로그인 성공
					location.reload();
				}
				else if(data == '1') {
					$('label[for="login_email"]').html('이메일: <span style="color:red; float:right;">등록된 이메일이 아님.</span>');
				}
				else if(data == '2') {
					$('label[for="login_password"]').html('비밀번호: <span style="color:red; float:right;">비밀번호가 틀림.</span>');
				}
			});
		});
		$('#login_cancel').click(function(){
			$form.get(0).reset();
			$('label[for="login_email"]').html('이메일:');
			$('label[for="login_password"]').html('비밀번호:');
			pLogin.hide();
		});
	});
</script>
</head>
<body>

<div id="s_menu_lgn_frm">
	<form>
	<fieldset>
		<legend>로그인 입력폼</legend>
		<p>
			<label for='login_email'>이메일:</label>
			<input name='login_email' id='login_email' type='text' />
		</p>
		<p>
			<label for='login_password'>비밀번호:</label>
			<input name='login_password' id='login_password' type='password' />
		</p>
		<p>
			<input name='login_maintain' id='login_maintain' type='checkbox' />
			<label for='login_maintain'>로그인 유지</label>
		</p>
		<p>
			<span class="txt_blue_btn" id='login_btn'>로그인</span>
			<span class="txt_blue_btn" id='login_cancel'>취소</span>
		</p>
	</fieldset>
	</form>
</div>

</body>
</html>